{extend name="public/main" /}

{block name="body"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list">
            <form action="{:request()->url()}" method="post" class="xn_ajax" data-type="open">
                <div class="layui-form-item">
                    <label class="layui-form-label">上级ID</label>
                    <div class="layui-input-block">
                        <select name="pid" lay-verify="required">
                            <option value="0">顶级分类</option>
                            {foreach name="list" item="vo"}
                            <option value="{$vo.id}" {if condition="$pid eq $vo['id']"}selected{/if} >{$vo._name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">操作名</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" lay-verify="required" placeholder="操作名" autocomplete="off" class="layui-input" value="{$data.title?$data.title:''}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用/插件名</label>
                    <div class="layui-input-block">
                        <input type="text" name="app_name"  placeholder="(非必填)规则所属应用名字或插件名字" autocomplete="off" class="layui-input" value="{$data.app_name?$data.app_name:''}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">权限分类</label>
                    <div class="layui-input-block">
                        {if !empty($data.type)}
                        <input type="radio" name="type"  value="system"  title="系统"   {$data.type=='system' ? 'checked':'' } >
                        <input type="radio" name="type"  value="plugin"  title="插件"  {$data.type=='plugin' ?  'checked':'' }>
                        <input type="radio" name="type"  value="app"     title="应用"  {$data.type=='app' ?  'checked':'' }>
                        {else/}
                        <input type="radio" name="type"  value="system"  title="系统" checked >
                        <input type="radio" name="type"  value="plugin"  title="插件">
                        <input type="radio" name="type"  value="app"  title="应用">
                        {/if}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">后台URL</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" placeholder="（非菜单节点可不填）  例：模块/控制器/方法 " autocomplete="off" class="layui-input" value="{$data.name?$data.name: ''}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">权限标识</label>
                    <div class="layui-input-block">
                        <input type="text" name="auth_name" lay-verify="required" placeholder="英文唯一标识 全小写 多值“_”隔开"   onkeyup="this.value=this.value.replace(/[^\w_]/g,'');" autocomplete="off" class="layui-input" value="{$data.auth_name?$data.auth_name: ''}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">参数</label>
                    <div class="layui-input-block">
                        <input type="text" name="param" placeholder="参数名，多值&拼接，例如：id=2&code=20" autocomplete="off" class="layui-input" value="{$data.param?$data.param:''}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">target属性(iframe)</label>
                    <div class="layui-input-block">
                        <input type="text" name="target" lay-verify="required" placeholder="选填：_self , _blank , _parent , _top"  onkeyup="this.value=this.value.replace(/[^\w_]/g,'');" autocomplete="off" class="layui-input" value="{$data.target?$data.target:''}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设为菜单</label>
                    <div class="layui-input-block">
                        {if !empty($data.ismenu)}
                        <input type="radio" name="ismenu"  value="0"  title="否"   {$data.ismenu==0 ? 'checked':'' } >
                        <input type="radio" name="ismenu"  value="1"  title="是"  {$data.ismenu==1 ?  'checked':'' }>
                        {else/}
                        <input type="radio" name="ismenu"  value="0"  title="否" checked >
                        <input type="radio" name="ismenu"  value="1"  title="是">
                        {/if}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜单icon</label>
                    <div class="layui-input-inline">
                        <input type="text" name="icon" id="icon" placeholder="" autocomplete="off" class="layui-input" value="{$data.icon?$data.icon:''}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="getNum()">选择图标</button>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" name="remark" placeholder="备注" autocomplete="off" class="layui-input" value="{$data.remark?$data.remark:''}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name="js"}

<script>

    var table;
    var laydate;
    var util;
    var	$;
    var result = "";
    var form;
    var auth_status = '';
    var dtree;
    layui.use(['form', 'table','util','laydate','layer','element'],function() {
        $ = layui.jquery;
        var util = layui.util,layer = layui.layer ,element = layui.element;
        table = layui.table;
        form = layui.form;
        laydate = layui.laydate;


    })

    //粉丝
    function getNum(){

        layer.open({
            type: 2,
            title: '图标列表',
            shade: 0.8,
            //closeBtn: 0, //不显示关闭按钮
            shade: [0],
            shadeClose: true,//单机空白处消失
            maxmin: true,
            //anim: 4, //动画类型
            area: ['40%','90%'],
            content:"{:Url('public_common/icon')}",
            btn: ['选择图标'],
            yes: function(index, layero){

                var nodeName = window["layui-layer-iframe" + index];//父页面引用
                var icon = nodeName.getIcon();
                if(icon!=false){
                    $('#icon').val(icon);
                    layer.close(index);
                    //处理重复提交
                }





            }
        });
    }
</script>
{/block}